package com.oos.zone.wechat.mp.service.handler;

import lombok.extern.log4j.Log4j2;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Service;

import java.util.Locale;
import java.util.concurrent.CompletableFuture;

/**
 * 功能描述：
 *
 * @author 拓金辉
 * @version 1.0
 * @date 2021-08-09 13:12:31
 */
@Log4j2
@Service
public class WxMpScanCodeMessageHandler extends AbstractWxMpMessageHandler {

    @Override
    public WxMpXmlOutMessage handle0() {
        final String msgType = wxMessage.getMsgType();
        if (msgType == null || msgType.isEmpty()) {
            return defaultTextMessage;
        }
        switch (msgType.toLowerCase(Locale.ROOT)) {
            case "scancode_push":
                return scancodePush();
            case "scancode_waitmsg":
                return scancodeWaitmsg();
            default:
                log.error("\n\n【事件类型未处理】\n\n {}", wxMessage.toString());
                return defaultTextMessage;
        }
    }

    public WxMpXmlOutMessage scancodePush() {
        CompletableFuture.runAsync(() -> log.info("扫码推事件的事件推送\n"), executor);
        return defaultTextMessage;
    }

    public WxMpXmlOutMessage scancodeWaitmsg() {
        CompletableFuture.runAsync(() -> log.info("扫码推事件且弹出“消息接收中”提示框的事件推送\n"), executor);
        return defaultTextMessage;
    }

}
